Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mesh vertex spacing #323

Merged
merged 1 commit into from
Feb 18, 2024
Merged

Fix mesh vertex spacing #323

merged 1 commit into from
Feb 18, 2024

Conversation

TokisanGames
Copy link
Owner

@TokisanGames TokisanGames commented Feb 13, 2024

#296 Mesh scaling did not address Storage or Editor. Only the mouse position was scaled. This means get_height and other storage functions didn't work.

This PR adds on to the work done by @lfxu to ensure the API is global. That is all function calls (eg get_height) operate in absolute global positions. If looking at the height of a mountain peak with get_height(512, 512), then you set vertex spacing to 2.0, you'll need to query that mountain peak with get_height(1024, 1024).

Working

  • Add/remove regions
  • Storage.get_height
  • Storage.get_normal
  • Collision
  • Brushing
  • Brush decal size
  • Picker decals
  • Importing - works fine using scaled global positions
  • Navigation doesn't generate. With spacing=2, even a very small area produces no nav mesh.
  • Baking array mesh and Occlusion culling off
  • Slope sculpting, heights are a little off
  • Edited AABB - The idea is internally it is in descaled coordinates. What it receives and gives externally are absolute global coordinates.

@TokisanGames TokisanGames added bug Something isn't working important High priority labels Feb 13, 2024
@TokisanGames TokisanGames force-pushed the fix-vertex-spacing branch 6 times, most recently from ea1dc42 to 3ce0e89 Compare February 15, 2024 20:44
@TokisanGames TokisanGames changed the title Fix mesh scaling (wip) Fix mesh vertex spacing (wip) Feb 15, 2024
@tcoxon
Copy link
Contributor

tcoxon commented Feb 16, 2024

This commit fixes some of the issues with ArrayMesh, Occluder3D and NavigationMesh baking. Basically, a few places scale the wrong thing, giving the output the appearance of having been scaled twice.

Unfortunately there still seems to be some kind of issue specifically with navmesh baking that I don't have time to look into at the moment. It could be another navmesh-related engine issue, because baking other kinds of meshes shows no issues here.
image

I've only briefly looked at the effect of vertex spacing on slope sculpting. It appears to be "spiky" whenever vertex spacing is below or above 1.

@TokisanGames
Copy link
Owner Author

TokisanGames commented Feb 16, 2024

Thank you, I have added the fix for the arraymesh/occlusion/navigation generation. I also simplified the scaling code.

I generated a section and it seems fine. Note that with 3x mesh scaling, the total size of the navigation mesh increases 3x. There is a finite limit on the size of what can be generated, so I painted a much smaller navigable section and it generated fine. I've never tried any AABB nav mesh generation so don't know what is working properly or not.

I also fixed the last row of collision and am looking at the dithered brushing now.

@TokisanGames
Copy link
Owner Author

I fixed the dithered brush and slope sculpting heights. The only remaining things are: AABB, and reviewing the code.

@TokisanGames
Copy link
Owner Author

@tcoxon Edited aabb is wrong in the main tree. Flattening the demo mountain peak w/ vertex scaling:

  • @ 1 Terrain3DStorage::add_edited_area: [P: (513.7451, 336.2854, 613.7875), S: (50, 26.30222, 50)]
  • @ 2 Terrain3DStorage::add_edited_area: [P: (521.157, 339.005, 623.036), S: (50, 26.07883, 50)]
  • @ 0.5 Terrain3DStorage::add_edited_area: [P: (509.7927, 335.5546, 604.967), S: (50, 26.65845, 50)]

This pr:

  • @ 1 Terrain3DStorage::add_edited_area: [P: (511.0797, 333.2357, 614.1357), S: (50, 31.5379, 50)]
  • @ 2 Terrain3DStorage::add_edited_area: [P: (1058.114, 355.972, 1258.456), S: (50, 9.005615, 50)]
  • @ 0.5 Terrain3DStorage::add_edited_area: [P: (241.0488, 284.7164, 292.0633), S: (50, 80.21317, 50)]

That scaling looks right to me. I think this PR is now done.

@TokisanGames TokisanGames marked this pull request as ready for review February 17, 2024 08:20
@TokisanGames TokisanGames changed the title Fix mesh vertex spacing (wip) Fix mesh vertex spacing Feb 17, 2024
@TokisanGames
Copy link
Owner Author

@tcoxon I'm going to merge this in so we can get more people using and testing. If there's a specific problem with edited_area we can follow up in another issue. Hopefully before I release 0.9.1, but I want to release it soon. Maybe today.

@TokisanGames TokisanGames merged commit 4220fb7 into main Feb 18, 2024
12 checks passed
@TokisanGames TokisanGames deleted the fix-vertex-spacing branch February 18, 2024 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working important High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants